<template>
	<view>
		<view class="flex justify-between item-box" v-for="(item,index) in cityList" :key="index" @click="back(index)">
			<view class="name">{{item.name}}</view>
			<u-icon name="arrow-right"></u-icon>
		</view>
  <!--列表为空时显示暂无数据-->
    <view v-if="cityList.length === 0" class="flex justify-center ">
        <view class="empty">暂无数据~</view>
    </view>
	</view>
</template>

<script>
	import {
		selectArea
	} from '@/api/home'
	export default {
		data() {
			return {
				cityList: []
			}

		},
		onLoad() {
			this.getCity()
		},
		methods: {
			getCity() {
				selectArea().then(res => {
					this.cityList = res.data;

				})
			},
			back(index) {
				const pages = getCurrentPages();
				const currPage = pages[pages.length - 1];
				const prevPage = pages[pages.length - 2];
				// 该方法在微信小程序失效
				// prevPage.setData.reservation = reservation
				uni.setStorageSync('location',this.cityList[index])
				this.$store.commit('SET_LOCATION',this.cityList[index])
				// this.$store.commit('location/SET_AD_INFO',adInfo)
				// prevPage.$vm.location = this.cityList[index]
				// prevPage.$vm.getList()

				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #fff;
	}
	.item-box {
		width: 690rpx;
		padding: 30rpx 0;
		background-color: #fff;
		border-bottom: 1px solid #999;
		margin-left: 30rpx;
		margin-top: 30rpx;
	}
	.name{
		font-family: PingFang SC, PingFang SC;
		font-weight: bold;
		font-size: 28rpx;
		color: #000000;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}
  .empty{
    font-weight: 500;
    font-size: 24rpx;
    color: #B5B5B5;
    text-align: center;
    margin-top: 40rpx;
    margin-bottom: 28rpx;
  }
</style>
